package health.lm.com.mine.present;

import com.scwang.smartrefresh.layout.SmartRefreshLayout;

import health.lm.com.component_base.base.mvp.contract.XPresent;
import health.lm.com.mine.entity.ThinkTankItemEntity;
import health.lm.com.mine.fragment.ThinkTankItemFragment;
import health.lm.com.mine.model.MineModel;
import health.lm.com.network.callback.SimpleCallBack;
import health.lm.com.network.exception.ApiException;

/**
 * @author GQI
 * @description: 智库
 * @date :2019-08-10 14:59
 */
public class ThinkTankItemPresent extends XPresent<ThinkTankItemFragment> {
    public void getListMore(boolean isRefresh, Object layout,String id ,int page, int pageSize) {
        MineModel.getInstance().thinkTankList(id, page, pageSize, new SimpleCallBack<ThinkTankItemEntity>() {
            @Override
            public void onSuccess(ThinkTankItemEntity entity) {

                if (hasV()) {
                    getV().getDataSuccess(entity.getNews_list());
                }
                if (isRefresh) {
                    ((SmartRefreshLayout)layout).finishRefresh(true);
                }
            }

            @Override
            public void onError(ApiException e) {
                super.onError(e);
                if (isRefresh) {
                    ((SmartRefreshLayout)layout).finishRefresh(true);
                }
            }
        });
    }
}
